package base

import (
	"HandWritingJVM/rtda"
	"HandWritingJVM/rtda/heap"
)

func InvokeMethod(invokerFrame *rtda.Frame, method *heap.Method) {
	thread := invokerFrame.Thread()
	newFrame := thread.NewFrame(method)
	thread.PushFrame(newFrame)
	argSlotSlot := int(method.ArgSlotCount())
	for i := argSlotSlot - 1; i >=0 ; i-- {
		slot := invokerFrame.OperandStack().PopSlot()
		newFrame.LocalVars().SetSlot(uint(i), slot)
	}
}
